package daybook.io.args;

import com.beust.jcommander.Parameter;
import com.beust.jcommander.Parameters;
import daybook.io.formatter.Format;

import static daybook.Resources.RESOURCES_NAME;
import static daybook.Resources.Usages.OUTPUT_FORMAT;

@Parameters(separators = "=", resourceBundle = RESOURCES_NAME)
public class FormatArgs {
    private static final Format DEFAULT_FORMAT = Format.STRING;
    @Parameter(names = {"--format"}, arity = 1,
            descriptionKey = OUTPUT_FORMAT,
            validateWith = FormatValidator.class,
            converter = FormatConverter.class)
    private Format format = null;

    public Format getFormat() {
        return format;
    }

    public Format getFormatWithDefault() {
        return format == null ? DEFAULT_FORMAT : format;
    }

    @Override
    public String toString() {
        return "FormatArgs{" +
                "format=" + format +
                '}';
    }
}
